<!--  -->
<template>
  <div class="header">
    <div class="title">
      <img src="../assets/温州银行.png" alt width="100px" />
      <p style="font-weight: 600;">{{title}}</p>
    </div>
    <el-menu
      :default-active="activeIndex"
      class="el-menu-demo"
      mode="horizontal"
      @select="handleSelect"
      background-color="#c2cfff"
      text-color="#fff"
      active-text-color="#faa61a"
      router
    >
      <el-menu-item index="/Workdesktop">工作桌面</el-menu-item>
      <el-menu-item index="/inventory">四清单</el-menu-item>
      <el-menu-item index="3">党员干部</el-menu-item>
      <el-menu-item index="4">政治生活</el-menu-item>
      <el-menu-item index="5">四报告</el-menu-item>
      <el-menu-item index="6">民主生活会</el-menu-item>
    </el-menu>
    <div class="user">
      <el-dropdown @command="handleCommand">
        <span class="el-dropdown-link">
          欢迎您，{{username}}
          <i class="el-icon-arrow-down el-icon--right"></i>
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item command="1">修改密码</el-dropdown-item>
          <el-dropdown-item command="2">退出登录</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </div>
</template>

<script>
export default {
  name: "Header",
  data() {
    return {
      activeIndex: "/Workdesktop",
      title: process.env.VUE_APP_NAME
    };
  },
  computed: {
    username(){
      return this.$store.state.login.username
    }
  },
  //生命周期 - 创建完成（访问当前this实例）
  created() {},
  //生命周期 - 挂载完成（访问DOM元素）
  mounted() {
  },
  //事件方法
  methods: {
    handleSelect(key, keyPath) {
      console.log(key, keyPath);
    },
    // 下拉菜单事件
    handleCommand(command) {
      switch (command) {
        case "1":
          break;
        case "2":
          this.quitLogin();
          break;
        default:
          break;
      }
    },
    // 退出登录
    quitLogin() {
      this.$router.push({
        path: "/login"
      });
    }
  }
};
</script>
<style scoped lang='scss'>
/* @import url(); 引入css类 */
.title {
  display: flex;
  height: 60px;
  align-items: center;
  img {
    margin-right: 10px;
  }
}
.header {
  display: flex;
  justify-content: space-between;
}

.el-dropdown-link {
  cursor: pointer;
  color: #faa61a;
}
.el-icon-arrow-down {
  font-size: 12px;
}
</style>